package rbtree;


import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import rbtree.RBNode.Color;

/**
 * Projeto : Arvore Preta e Vermelha
 * 
 * Equipe:
 * 			Antonio Eduardo
 * 			Gabriel de Brito
 * 			Gervasio Costa
 * 			Jordan Ferreira
 * 			Wesley Breno
 * 
 */

public class RBTreeImplTest {

//	< --------------------------------------------------------- >
//	COMPLETOS EM:
//		 -> METODOS DE PROPRIEDADES!
//		 -> INSERT ( TODOS OS CASOS! )	( CASO 3, TIO EH RED E AVO EH ROOT ) -> CASO TRATADO EM testFilhoRedEhBlack!
//		 -> REMOVE ( REMOCAO DE FOLHA RED! )
//		 -> REMOVE ( REMOCAO DE NODE RED COM SUCESSOR RED! ( LEFT-RIGHT ))
//		 -> REMOVE ( REMOCAO DE NODE RED COM SUCESSOR BLACK! ( LEFT-RIGHT ))
//		 -> REMOVE ( REMOCAO DE FOLHA BLACK! )
//		 -> REMOVE ( REMOCAO DE NODE BLACK COM SUCESSOR RED! ( LEFT ))
//		 -> REMOVE ( REMOCAO DE NODE BLACK COM SUCESSOR BLACK! ( RIGHT ))
//	< --------------------------------------------------------- >

	  RBTreeImpl<Integer> myTree;
	    RBNode<Integer> NIL;
	     
	    @Before
	    public void before() {
	            myTree = new RBTreeImpl<Integer>();
	            NIL = new RBNode<Integer>();
	    }
	 
	    @Test
	    public void testInsertCaso1() {
	            //      INSERT ROOT                             -- CASO 1       ( EH ROOT )
	            myTree.insert(50);
	            Assert.assertTrue(myTree.getRoot().getData() == 50);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(myTree.getRoot().getLeft().equals( NIL ));
	            Assert.assertTrue(myTree.getRoot().getRight().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	    }
	 
	    @Test
	    public void testInsertCaso2() {
	            myTree.insert(50);
	            // INSERT CHILD Right           -- CASO 2       ( PARENT EH PReTO )
	            myTree.insert(75);      // ADD RIGHT
	            RBNode<Integer> nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 75);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	            Assert.assertTrue(nodeRight.getColor() == Color.RED );
	             
	            myTree.insert(25);      // ADD LEFT
	            RBNode<Integer> nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 25);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getColor() == Color.RED );
	    }
	     
	    @Test
	    public void testInsertCaso3LeftPerna() {
	            myTree.insert(50);
	            myTree.insert(25);
	            myTree.insert(75);
	            // INSERT CHILD Right           -- CASO 3       ( Pai e tio sao red )
	            myTree.insert(0);       // ADD LEFT
	            RBNode<Integer> nodeLeft;
	            RBNode<Integer> nodeRight;
	            Assert.assertTrue(myTree.getRoot().getData() == 50);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 25);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot() ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	            nodeLeft = (RBNode<Integer>) nodeLeft.getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 0);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot().getLeft() ));
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getColor() == Color.RED );
	            nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 75);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot() ));
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	            Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	    }
	 
	    @Test
	    public void testInsertCaso3LeftJoelho() {
	            myTree.insert(50);
	            myTree.insert(25);
	            myTree.insert(75);
	            // INSERT CHILD Right           -- CASO 3       ( Pai e tio sao red )
	            myTree.insert(30);      // ADD LEFT
	            RBNode<Integer> nodeLeft;
	            RBNode<Integer> nodeRight;
	            Assert.assertTrue(myTree.getRoot().getData() == 50);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 25);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot() ));
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	            nodeRight = (RBNode<Integer>) nodeLeft.getRight();
	            Assert.assertTrue(nodeRight.getData() == 30);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot().getLeft() ));
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	            Assert.assertTrue(nodeRight.getColor() == Color.RED );
	            nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 75);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot() ));
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	            Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	    }
	     
	    @Test
	    public void testInsertCaso3RightPerna() {
	            myTree.insert(50);
	            myTree.insert(25);
	            myTree.insert(75);
	            // INSERT CHILD Right           -- CASO 3       ( Pai e tio sao red )
	            myTree.insert(100);     // ADD RIGHT
	            RBNode<Integer> nodeLeft;
	            RBNode<Integer> nodeRight;
	            Assert.assertTrue(myTree.getRoot().getData() == 50);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 25);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot() ));
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	            nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 75);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot() ));
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	            nodeRight = (RBNode<Integer>) nodeRight.getRight();
	            Assert.assertTrue(nodeRight.getData() == 100);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot().getRight() ));
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	            Assert.assertTrue(nodeRight.getColor() == Color.RED );
	    }
	     
	    @Test
	    public void testInsertCaso3RightJoelho() {
	            myTree.insert(50);
	            myTree.insert(25);
	            myTree.insert(75);
	            // INSERT CHILD Right           -- CASO 3       ( Pai e tio sao red )
	            myTree.insert(70);      // ADD RIGHT
	            RBNode<Integer> nodeLeft;
	            RBNode<Integer> nodeRight;
	            Assert.assertTrue(myTree.getRoot().getData() == 50);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 25);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot() ));
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	            nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 75);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot() ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	            Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	            nodeLeft = (RBNode<Integer>) nodeRight.getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 70);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot().getRight() ));
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getColor() == Color.RED );
	    }
	     
	    @Test
	    public void testInsertCaso4Left() {
	            myTree.insert(50);
	            myTree.insert(0);
	            // INSERT CHILD Right           -- CASO 4.2 ( PARENT EH RED E FAZ PERNA ) na esquerda
	            myTree.insert(25);
	            Assert.assertTrue(myTree.getRoot().getData() == 25);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            RBNode<Integer> nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 0);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getColor() == Color.RED );
	            RBNode<Integer> nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 50);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	            Assert.assertTrue(nodeRight.getColor() == Color.RED );
	    }
	 
	    @Test
	    public void testInsertCaso4Right() {
	            myTree.insert(50);
	            myTree.insert(100);
	            // INSERT CHILD Right           -- CASO 4.1 ( PARENT EH RED E FAZ PERNA ) na direita
	            myTree.insert(75);
	            Assert.assertTrue(myTree.getRoot().getData() == 75);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            RBNode<Integer> nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 50);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getColor() == Color.RED );
	            RBNode<Integer> nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 100);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	            Assert.assertTrue(nodeRight.getColor() == Color.RED );
	    }
	 
	    @Test
	    public void testInsertCaso5Left() {
	            myTree.insert(50);
	            myTree.insert(25);
	            // INSERT CHILD Right           -- CASO 5.2 ( PARENT EH RED E FAZ PERNA ) na esquerda
	            myTree.insert(0);
	            Assert.assertTrue(myTree.getRoot().getData() == 25);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            RBNode<Integer> nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 0);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getColor() == Color.RED );
	            RBNode<Integer> nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 50);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	            Assert.assertTrue(nodeRight.getColor() == Color.RED );
	    }
	     
	    @Test
	    public void testInsertCaso5Righ() {
	            myTree.insert(50);
	            myTree.insert(75);
	            // INSERT CHILD Right           -- CASO 5.1 ( PARENT EH RED E FAZ PERNA ) na direita
	            myTree.insert(100);
	            Assert.assertTrue(myTree.getRoot().getData() == 75);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            RBNode<Integer> nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 50);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getColor() == Color.RED );
	            RBNode<Integer> nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 100);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	            Assert.assertTrue(nodeRight.getColor() == Color.RED );
	    }
	     
	    @Test
	    public void testRemoveFolhaRED() {
	            myTree.insert(50);
	            myTree.insert(75);
	            myTree.insert(100);
	            // CASO 1 -> O FILHO EH RED E EH FOLHA!
	            myTree.remove(50);
	            Assert.assertTrue(myTree.getRoot().getData() == 75);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            Assert.assertTrue(myTree.getRoot().getLeft().equals( NIL ));
	            RBNode<Integer> nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 100);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	            Assert.assertTrue(nodeRight.getColor() == Color.RED );
	            myTree.remove(100);
	            Assert.assertTrue(myTree.getRoot().getData() == 75);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            Assert.assertTrue(myTree.getRoot().getLeft().equals( NIL ));
	            Assert.assertTrue(myTree.getRoot().getRight().equals( NIL ));
	    }
	     
	    @Test
	    public void testRemoveREDSucessorREDLeft() {
	            myTree.insert(50);
	            myTree.insert(30);
	            myTree.insert(60);
	            myTree.insert(20);
	            myTree.insert(40);
	            myTree.insert(35);
	            // CASO 1 -> O FILHO EH RED E SUCESSOR EH RED!
	            myTree.remove(30);
	            RBNode<Integer> nodeLeft;
	            RBNode<Integer> nodeRight;
	            Assert.assertTrue(myTree.getRoot().getData() == 50);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 35);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeLeft.getColor() == Color.RED );
	            nodeRight = (RBNode<Integer>) nodeLeft.getRight();
	            Assert.assertTrue(nodeRight.getData() == 40);
	            Assert.assertTrue(nodeRight.getParent().equals(nodeLeft));
	            Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	            nodeLeft = (RBNode<Integer>) nodeLeft.getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 20);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot().getLeft()));
	            Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 60);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	    }
	     
	    @Test
	    public void testRemoveREDSucessorREDRight() {
	            myTree.insert(50);
	            myTree.insert(40);
	            myTree.insert(70);
	            myTree.insert(60);
	            myTree.insert(75);
	            myTree.insert(72);
	            // CASO 1.2.right -> O FILHO EH RED E SUCESSOR EH RED!
	            myTree.remove(70);
	            RBNode<Integer> nodeLeft;
	            RBNode<Integer> nodeRight;
	            Assert.assertTrue(myTree.getRoot().getData() == 50);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 40);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 72);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeRight.getColor() == Color.RED );
	            nodeLeft = (RBNode<Integer>) nodeRight.getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 60);
	            Assert.assertTrue(nodeLeft.getParent().equals( nodeRight ));
	            Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            nodeRight = (RBNode<Integer>) nodeRight.getRight();
	            Assert.assertTrue(nodeRight.getData() == 75);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot().getRight()));
	            Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	    }
	     
	    @Test
	    public void testRemoveREDSucessorBLACKLeft() {
	            myTree.insert(50);
	            myTree.insert(30);
	            myTree.insert(60);
	            myTree.insert(20);
	            myTree.insert(40);
	            myTree.insert(35);
	            myTree.remove(30);
	            // CASO 1 -> O FILHO EH RED E SUCESSOR EH BLACK!
	            myTree.remove(35);
	            RBNode<Integer> nodeLeft;
	            RBNode<Integer> nodeRight;
	            Assert.assertTrue(myTree.getRoot().getData() == 50);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 40);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            nodeLeft = (RBNode<Integer>) nodeLeft.getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 20);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot().getLeft()));
	            Assert.assertTrue(nodeLeft.getColor() == Color.RED );
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 60);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	    }
	     
	    @Test
	    public void testRemoveREDSucessorBLACKRight() {
	            myTree.insert(50);
	            myTree.insert(40);
	            myTree.insert(70);
	            myTree.insert(60);
	            myTree.insert(75);
	            myTree.insert(72);
	            myTree.remove(70);
	            // CASO 1.3.right -> O FILHO EH RED E SUCESSOR EH BLACK!
	            myTree.remove(72);
	            RBNode<Integer> nodeLeft;
	            RBNode<Integer> nodeRight;
	            Assert.assertTrue(myTree.getRoot().getData() == 50);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 40);
	            Assert.assertTrue(nodeLeft.getParent().equals(myTree.getRoot()));
	            Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 75);
	            Assert.assertTrue(nodeRight.getParent().equals(myTree.getRoot()));
	            Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	            nodeLeft = (RBNode<Integer>) nodeRight.getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 60);
	            Assert.assertTrue(nodeLeft.getParent().equals(nodeRight));
	            Assert.assertTrue(nodeLeft.getColor() == Color.RED );
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	    }
	 
	    @Test
	    public void testRemoveFolhaBLACKIrmaoREDLeft(){
	        myTree.insert(50);
	        myTree.insert(30);
	        myTree.insert(70);
	        myTree.insert(60);
	        myTree.insert(80);
	        myTree.insert(90);
	        myTree.remove(90);
	        //////////////////////////////////////////////////////////////
	        myTree.remove(30);
	        RBNode<Integer> nodeLeft;
	        RBNode<Integer> nodeRight;
	        Assert.assertTrue(myTree.getRoot().getData() == 70);
	        Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	        Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	        nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	        Assert.assertTrue(nodeLeft.getData() == 50);
	        Assert.assertTrue(nodeLeft.getParent().equals(myTree.getRoot()));
	        Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	        Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	        nodeRight = (RBNode<Integer>) nodeLeft.getRight();
	        Assert.assertTrue(nodeRight.getData() == 60);
	        Assert.assertTrue(nodeRight.getParent().equals(nodeLeft));
	        Assert.assertTrue(nodeRight.getColor() == Color.RED );
	        Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	        nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	        Assert.assertTrue(nodeRight.getData() == 80);
	        Assert.assertTrue(nodeRight.getParent().equals(myTree.getRoot()));
	        Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	        Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	    }
	     
	    @Test
	    public void testRemoveFolhaBLACKIrmaoREDRight(){
	        myTree.insert(50);
	        myTree.insert(30);
	        myTree.insert(70);
	        myTree.insert(20);
	        myTree.insert(40);
	        myTree.insert(45);
	        myTree.remove(45);
	        //////////////////////////////////////////////////////////////
	        myTree.remove(70);
	        RBNode<Integer> nodeLeft;
	        RBNode<Integer> nodeRight;
	        Assert.assertTrue(myTree.getRoot().getData() == 30);
	        Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	        Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	        nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	        Assert.assertTrue(nodeLeft.getData() == 20);
	        Assert.assertTrue(nodeLeft.getParent().equals(myTree.getRoot()));
	        Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	        Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	        nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	        Assert.assertTrue(nodeRight.getData() == 50);
	        Assert.assertTrue(nodeRight.getParent().equals(myTree.getRoot()));
	        Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	        Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	        nodeLeft = (RBNode<Integer>) nodeRight.getLeft();
	        Assert.assertTrue(nodeLeft.getData() == 40);
	      //  Assert.assertTrue(nodeLeft.getParent().equals(myTree.getRoot()));
	        Assert.assertTrue(nodeLeft.getColor() == Color.RED );
	        Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	    }
	     
	    @Test
	    public void testRemoveFolhaBLACKIrmaoBLACKSemSobrinhosLeft() {
	        myTree.insert(50);
	        myTree.insert(40);
	        myTree.insert(60);
	        myTree.insert(70);
	        myTree.remove(70);
	        //////////////////////////////////////////////////////////////
	        myTree.remove(40);
	        RBNode<Integer> nodeRight;
	        Assert.assertTrue(myTree.getRoot().getData() == 50);
	        Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	        Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	        Assert.assertTrue(myTree.getRoot().getLeft().equals( NIL ));
	        nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	        Assert.assertTrue(nodeRight.getData() == 60);
	        Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	        Assert.assertTrue(nodeRight.getColor() == Color.RED );
	        Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	    }
	     
	    @Test
	    public void testRemoveFolhaBLACKIrmaoBLACKUmSobrinhosCaso1Left() {
	        // sobrinho eh left
	        myTree.insert(50);
	        myTree.insert(40);
	        myTree.insert(60);
	        myTree.insert(55);
	        //////////////////////////////////////////////////////////////
	        myTree.remove(40);
	        RBNode<Integer> nodeLeft;
	        RBNode<Integer> nodeRight;
	        Assert.assertTrue(myTree.getRoot().getData() == 55);
	        Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	        Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	        nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	        Assert.assertTrue(nodeLeft.getData() == 50);
	        Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	        Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	        Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	        nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	        Assert.assertTrue(nodeRight.getData() == 60);
	        Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	        Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	        Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	    }
	     
	    @Test
	    public void testRemoveFolhaBLACKIrmaoBLACKUmSobrinhosCaso2Left() {
	        // sobrinho eh right
	        myTree.insert(50);
	        myTree.insert(40);
	        myTree.insert(60);
	        myTree.insert(70);
	        //////////////////////////////////////////////////////////////
	        myTree.remove(40);
	        RBNode<Integer> nodeLeft;
	        RBNode<Integer> nodeRight;
	        Assert.assertTrue(myTree.getRoot().getData() == 60);
	        Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	        Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	        nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	        Assert.assertTrue(nodeLeft.getData() == 50);
	        Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	        Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	        Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	        nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	        Assert.assertTrue(nodeRight.getData() == 70);
	        Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	        Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	        Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	    }
	     
	    @Test
	    public void testRemoveFolhaBLACKIrmaoBLACKDoisSobrinhosREDLeft(){
	        myTree.insert(50);
	        myTree.insert(40);
	        myTree.insert(60);
	        myTree.insert(65);
	        myTree.insert(55);
	        //////////////////////////////////////////////////////////////
	        myTree.remove(40);
	        RBNode<Integer> nodeLeft;
	        RBNode<Integer> nodeRight;
	        Assert.assertTrue(myTree.getRoot().getData() == 60);
	        Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	        Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	        nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	        Assert.assertTrue(nodeLeft.getData() == 50);
	        Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	        Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	        Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	        nodeRight = (RBNode<Integer>) nodeLeft.getRight();
	        Assert.assertTrue(nodeRight.getData() == 55);
	        Assert.assertTrue(nodeRight.getParent().equals( nodeLeft ));
	        Assert.assertTrue(nodeRight.getColor() == Color.RED );
	        Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	        nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	        Assert.assertTrue(nodeRight.getData() == 65);
	        Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	        Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	        Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	    }
	     
	    ////////////////////////////////////////////////////////////////////////////////////////
	     
	    @Test
	    public void testRemoveFolhaBLACKIrmaoBLACKSemSobrinhosRight() {
	        myTree.insert(50);
	        myTree.insert(40);
	        myTree.insert(60);
	        myTree.insert(70);
	        myTree.remove(70);
	        //////////////////////////////////////////////////////////////
	        myTree.remove(60);
	        RBNode<Integer> nodeLeft;
	        Assert.assertTrue(myTree.getRoot().getData() == 50);
	        Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	        Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	        Assert.assertTrue(myTree.getRoot().getRight().equals( NIL ));
	        nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	        Assert.assertTrue(nodeLeft.getData() == 40);
	        Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	        Assert.assertTrue(nodeLeft.getColor() == Color.RED );
	        Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	    }
	     
	    @Test
	    public void testRemoveFolhaBLACKIrmaoBLACKUmSobrinhosCaso1Right() {
	        myTree.insert(50);
	        myTree.insert(40);
	        myTree.insert(60);
	        myTree.insert(45);
	        //////////////////////////////////////////////////////////////
	        myTree.remove(60);
	        RBNode<Integer> nodeLeft;
	        RBNode<Integer> nodeRight;
	        Assert.assertTrue(myTree.getRoot().getData() == 45);
	        Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	        Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	        nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	        Assert.assertTrue(nodeLeft.getData() == 40);
	        Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	        Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	        Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	        nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	        Assert.assertTrue(nodeRight.getData() == 50);
	        Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	        Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	        Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	    }
	     
	    @Test
	    public void testRemoveFolhaBLACKIrmaoBLACKUmSobrinhosCaso2Right() {
	        myTree.insert(50);
	        myTree.insert(40);
	        myTree.insert(60);
	        myTree.insert(30);
	        //////////////////////////////////////////////////////////////
	        myTree.remove(60);
	        RBNode<Integer> nodeLeft;
	        RBNode<Integer> nodeRight;
	        Assert.assertTrue(myTree.getRoot().getData() == 40);
	        Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	        Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	        nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	        Assert.assertTrue(nodeLeft.getData() == 30);
	        Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	        Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	        Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	        nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	        Assert.assertTrue(nodeRight.getData() == 50);
	        Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	        Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	        Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	    }
	     
	    @Test
	    public void testRemoveFolhaBLACKIrmaoBLACKDoisSobrinhosREDRight(){
	        myTree.insert(50);
	        myTree.insert(40);
	        myTree.insert(60);
	        myTree.insert(35);
	        myTree.insert(45);
	        //////////////////////////////////////////////////////////////
	        myTree.remove(60);
	        RBNode<Integer> nodeLeft;
	        RBNode<Integer> nodeRight;
	        Assert.assertTrue(myTree.getRoot().getData() == 40);
	        Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	        Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	        nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	        Assert.assertTrue(nodeLeft.getData() == 35);
	        Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	        Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	        Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	        nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	        Assert.assertTrue(nodeRight.getData() == 50);
	        Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	        Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	        Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	        nodeLeft = (RBNode<Integer>) nodeRight.getLeft();
	        Assert.assertTrue(nodeLeft.getData() == 45);
	        Assert.assertTrue(nodeLeft.getParent().equals( nodeRight));
	        Assert.assertTrue(nodeLeft.getColor() == Color.RED );
	        Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	        Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	    }
	     
	    @Test
	    public void testRemoveCaso2P1Left() {
	            myTree.insert(50);
	            myTree.insert(40);
	            myTree.insert(60);
	            myTree.insert(45);
	            //////////////////////////////////////////////////////////////
	            myTree.remove(60);
	            RBNode<Integer> nodeLeft;
	            RBNode<Integer> nodeRight;
	            Assert.assertTrue(myTree.getRoot().getData() == 45);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 40);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 50);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	    }
	     
	    @Test
	    public void testRemoveCaso2P1Right() {
	            myTree.insert(50);
	            myTree.insert(40);
	            myTree.insert(60);
	            myTree.insert(45);
	            // CASO 2P1 -> O FILHO EH BLACK E EH FOLHA!
	            myTree.remove(60);
	            RBNode<Integer> nodeLeft;
	            RBNode<Integer> nodeRight;
	            Assert.assertTrue(myTree.getRoot().getData() == 45);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 40);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 50);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	    }
	     
	    @Test
	    public void testRemoveCaso2P2Left() {
	            myTree.insert(50);
	            myTree.insert(40);
	            myTree.insert(60);
	            myTree.insert(45);
	            // CASO 2P2 -> O FILHO EH BLACK E SUCESSOR EH RED!
	            myTree.remove(40);
	            RBNode<Integer> nodeLeft;
	            RBNode<Integer> nodeRight;
	            Assert.assertTrue(myTree.getRoot().getData() == 50);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 45);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 60);
//	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot().getLeft()));
	            Assert.assertTrue(nodeRight.getColor() == Color.BLACK );
	            Assert.assertTrue(nodeRight.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeRight.getRight().equals( NIL ));
	    }
	     
	    @Test
	    public void testRemoveCaso2P3Right() {
	            myTree.insert(50);
	            myTree.insert(40);
	            myTree.insert(70);
	            myTree.insert(60);
	            myTree.insert(85);
	            myTree.insert(80);
	            myTree.insert(90);
	            // CASO 2P3 -> O FILHO EH BLACK E SUCESSOR EH BLACK!
	            myTree.remove(50);
	            RBNode<Integer> nodeLeft;
	            RBNode<Integer> nodeRight;
	            Assert.assertTrue(myTree.getRoot().getData() == 60);
	            Assert.assertTrue(myTree.getRoot().getParent().equals( NIL ));
	            Assert.assertTrue(((RBNode<Integer>) myTree.getRoot()).getColor() == Color.BLACK );
	            nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	            Assert.assertTrue(nodeLeft.getData() == 40);
	            Assert.assertTrue(nodeLeft.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeLeft.getColor() == Color.BLACK );
	            Assert.assertTrue(nodeLeft.getLeft().equals( NIL ));
	            Assert.assertTrue(nodeLeft.getRight().equals( NIL ));
	            nodeRight = (RBNode<Integer>) myTree.getRoot().getRight();
	            Assert.assertTrue(nodeRight.getData() == 85);
	            Assert.assertTrue(nodeRight.getParent().equals( (RBNode<Integer>) myTree.getRoot()));
	            Assert.assertTrue(nodeRight.getColor() == Color.RED );
	            nodeLeft = (RBNode<Integer>) myTree.getRoot().getLeft();
	    }
	     
	    // < --------------------------- Teste Propriedades! --------------------------- >
	     
	    @Test
	    public void testTodoNoTemCor() {
	            myTree.insert(50);
	            myTree.insert(25);
	            myTree.insert(75);
	            myTree.insert(10);
	            myTree.insert(30);
	            myTree.insert(35);
	            Assert.assertTrue( myTree.verifyNodeColor() );
	            ((RBNode<Integer>)myTree.getRoot()).color = null;
	            Assert.assertFalse( myTree.verifyNodeColor() );
	    }
	     
	    @Test
	    public void testTodoNilEhNegro() {
	            myTree.insert(50);
	            Assert.assertTrue( myTree.verifyBlackNILs() );
	            ((RBNode<Integer>) myTree.getRoot().getLeft()).setColor();
	            Assert.assertFalse( myTree.verifyBlackNILs() );
	    }
	     
	    @Test
	    public void testRaizNegra() {
	            myTree.insert(50);
	            Assert.assertTrue( myTree.verifyBlackRoot() );
	            ((RBNode<Integer>) myTree.getRoot()).setColor();
	            Assert.assertFalse( myTree.verifyBlackRoot() );
	    }
	     
	    @Test
	    public void testFilhoRedEhBlack() {
	            myTree.insert(50);
	            myTree.insert(25);
	            myTree.insert(75);
	            myTree.insert(10);
	            myTree.insert(30);
	            myTree.insert(35);
	            Assert.assertTrue( myTree.verifyRedChildren() );
	            ((RBNode<Integer>) myTree.getRoot().getLeft().getLeft()).setColor();
	            Assert.assertFalse( myTree.verifyRedChildren() );
	    }
	     
	    @Test
	    public void testBlackHeight() {
	            myTree.insert(50);
	            myTree.insert(25);
	            myTree.insert(75);
	            myTree.insert(20);
	            myTree.insert(30);
	            Assert.assertTrue( myTree.verifyBlackHeight() );
	            ((RBNode<Integer>) myTree.getRoot().getLeft().getLeft()).setColor();
	            Assert.assertFalse( myTree.verifyBlackHeight() );
	    }
	}